<template>
	<view class="padding">
		<view class="flex margin-xs padding-xs">
			<view><text class="cuIcon-friend text-blue"></text></view>
			<view class="margin-left text-blue">队伍名称</view>
		</view>
		<view class="cu-form-group solid-bottom">
			<input placeholder="请输入队伍名称" v-model="teamForm.name" name="input">
		</view>
		<!-- <view class="flex margin-xs padding-xs">
			<view><text class="cuIcon-data text-blue"></text></view>
			<view class="margin-left text-blue">日期选择</view>
		</view>
		<view class="flex padding-xs align-center">
			<view class="flex-sub padding-xs margin-xs bg-white">
				<picker mode="date" :value="date" start="2015-09-01" end="2020-09-01" @change="DateChange1">
					<view class="picker">
						{{ form.date1 }}
					</view>
				</picker>
			</view>

			<view class="text-blue text-xs">
				至
			</view>

			<view class="flex-sub padding-xs margin-xs bg-white">
				<picker mode="date" :value="date" start="2015-09-01" end="2020-09-01" @change="DateChange2">
					<view class="picker">
						{{ form.date2 }}
					</view>
				</picker>
			</view>
		</view> -->

		<view class="flex margin-xs padding-xs">
			<view><text class="cuIcon-emoji text-blue"></text></view>
			<view class="margin-left text-blue">团队人数</view>
		</view>
		<view class="cu-form-group solid-bottom">
			<input placeholder="请输入人数" name="input" v-model="teamForm.max_num">
		</view>

		<view class="flex margin-xs padding-xs">
			<view><text class="cuIcon-community text-blue"></text></view>
			<view class="margin-left text-blue">团队口号</view>
		</view>
		<view class="cu-form-group align-start">
			<textarea v-model="teamForm.detail" maxlength="-1" :disabled="modalName != null" @input="textareaBInput1" placeholder="请输入团队口号"></textarea>
		</view>



		<!-- <view class="flex margin-xs padding-xs">
			<view><text class="cuIcon-command text-blue"></text></view>
			<view class="margin-left text-blue">入队事项</view>
		</view>
		<view class="cu-form-group align-start">
			<textarea maxlength="-1" :disabled="modalName != null" @input="textareaBInput2" placeholder="请输入入队事项"></textarea>
		</view> -->
		<button @tap="createTeam" style="width: 100%; position: fixed;bottom: 0px;left: 0px;"
			class="cu-btn bg-blue margin-tb-sm lg">立即组建</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			teamForm:{
				innovation_id:'',
				name:'',
				max_num:'',
				detail:'',
			},
			form: {
				tname: '',
				date1: '2018-12-25',
				date2: '2018-12-25',
				num: '',
				kouhao: '',
				shixiang: ''
			},

		}
	},
	onLoad(query) {
		// let token = JSON.parse(uni.getStorageSync('vuexvuex'))
		// var parsedData = JSON.parse(token.value);
		// var tokenValue = parsedData.userinfo.token;
		
		// 从 query 中获取传递的参数
		this.teamForm.innovation_id = query.id || '';
		console.log('this.teamForm.innovation_id: ', this.teamForm.innovation_id)
	
	},
	methods: {
		async createTeam(){
			if (this.teamForm.name == '' || this.teamForm.max_num == '' || this.teamForm.detail == '') {
				uni.showToast({
					title: '请填写完整信息',
					icon: 'none'
				})
			} else{
				let res = await this.$myHttp.post({
					
					url: this.$myHttp.urlMap.createTeam,
					data: this.teamForm
				})
				this.teamDetailList = res.data.detail
				if(res.code == 1){
					uni.showToast({
						title: '创建成功！',
						icon: 'success',
						
					})
					setTimeout(()=>{
						this.$openrul(`/pages/missionTeam/missionTeam`);
					}, 1000)
					
				}
				
			}
			
		},
		DateChange1(e) {
			console.log('%c [ e ]-48', 'font-size:13px; background:pink; color:#bf2c9f;', e)
			this.form.date1 = e.detail.value

		},


		DateChange2(e) {
			console.log('%c [ e ]-54', 'font-size:13px; background:pink; color:#bf2c9f;', e)
			this.form.date2 = e.detail.value


		},
		textareaBInput1(e) {
			console.log('%c [ e ]-93', 'font-size:13px; background:pink; color:#bf2c9f;', e)
			this.form.kouhao = e.detail.value


		},
		textareaBInput2(e) {
			console.log('%c [ e ]-97', 'font-size:13px; background:pink; color:#bf2c9f;', e)
			this.form.shixiang = e.detail.value


		},
		//添加队伍
		add() {
			// 判断form的内容是否为空
			if (this.form.tname == '' || this.form.date1 == '' || this.form.date2 == '' || this.form.num == '' || this.form.kouhao == '' || this.form.shixiang == '') {
				uni.showToast({
					title: '请填写完整信息',
					icon: 'none'
				})
			} else {
				uni.showToast({
					title: '添加成功',
				})
				console.log('%c [ this.form ]-118', 'font-size:13px; background:pink; color:#bf2c9f;', this.form)
			}

		}
	}
}
</script>

<style></style>
